package com.ruoyi.web.hnsdsa.controller;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.web.hnsdsa.domain.FeeNumSet;
import com.ruoyi.web.hnsdsa.service.IFeeNumSetService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 价格设置Controller
 *
 * @author vallis
 * @date 2022-03-08
 */
@RestController
@RequestMapping("/fee/fee")
public class FeeNumSetController extends BaseController
{
    @Autowired
    private IFeeNumSetService feeNumSetService;

    /**
     * 查询价格设置列表
     */
    @PreAuthorize("@ss.hasPermi('fee:fee:list')")
    @GetMapping("/list")
    public TableDataInfo list(FeeNumSet feeNumSet)
    {
        startPage();
        List<FeeNumSet> list = feeNumSetService.selectFeeNumSetList(feeNumSet);
        return getDataTable(list);
    }

    /**
     * 导出价格设置列表
     */
    @PreAuthorize("@ss.hasPermi('fee:fee:export')")
    @Log(title = "价格设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FeeNumSet feeNumSet)
    {
        List<FeeNumSet> list = feeNumSetService.selectFeeNumSetList(feeNumSet);
        ExcelUtil<FeeNumSet> util = new ExcelUtil<FeeNumSet>(FeeNumSet.class);
        util.exportExcel(response, list, "价格设置数据");
    }

    /**
     * 获取价格设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('fee:fee:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(feeNumSetService.getById(id));
    }

    /**
     * 新增价格设置
     */
    @PreAuthorize("@ss.hasPermi('fee:fee:add')")
    @Log(title = "价格设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FeeNumSet feeNumSet) {
        return toAjax(feeNumSetService.save(feeNumSet));
    }

    /**
     * 修改价格设置
     */
    @PreAuthorize("@ss.hasPermi('fee:fee:edit')")
    @Log(title = "价格设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FeeNumSet feeNumSet) {
        return toAjax(feeNumSetService.updateById(feeNumSet));
    }

    /**
     * 删除价格设置
     */
    @PreAuthorize("@ss.hasPermi('fee:fee:remove')")
    @Log(title = "价格设置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(feeNumSetService.removeByIds(Arrays.asList(ids)));
    }
}
